package com.google.common.primitives;

import com.google.common.base.Preconditions;

public class UnsignedBytes {
    private static final int UNSIGNED_MASK = 0xFF;

    public static int toInt(byte value) {
        return value & UNSIGNED_MASK;
    }

    public static byte checkedCast(long value) {
        Preconditions.checkArgument(value >> Byte.SIZE == 0, "out of range: %s", value);
        return (byte) value;
    }
}
